<template>
  <div class="index">
    <div class="banner">
      <el-carousel :interval="5000" arrow="never" height="12rem">
        <el-carousel-item v-for="(item, index) in bannerimg" :key="index">
          <img :src="item.filepath" width="100%" height="100%" />
        </el-carousel-item>
      </el-carousel>
    </div>

    <div class="center">
      <h3 class="biao"><img src="../assets/jslb.jpg" /><span>教师列表</span></h3>
      <div class="box a">
        <div
          class="for"
          v-for="(item, index) in boxs"
          :key="index"
          @click="
            qhk(index);
            qhid(item.id);
          "
        >
          <div class="subs"><img src="../assets/tx.jpg" /></div>
          <div class="sub" :class="{ red: changeRed == index }">{{ item.subname }}</div>
        </div>
      </div>

      <div class="one">
        <div
          class="box"
          v-for="(item, index) in list"
          :key="index"
          @click="jieshao(item.id)"
        >
          <div class="touxiang"><img :src="item.filepath" /></div>
          <div>
            <div class="yh">
              {{ item.name }}<img v-show="item.sex == '2'" src="../assets/xb.png" /><img
                v-show="item.sex == '1'"
                src="../assets/nan.png"
              /><span>{{ item.subname }}</span
              ><span>教龄：{{ item.teach_year }}年</span>
            </div>
          </div>
          <div class="zwjs">教师风采</div>
        </div>
      </div>
      <h3 class="biao"><img src="../assets/jslb.jpg" /><span>评教系统</span></h3>
      <div class="boxs">
        <div v-for="(item, index) in box" :key="index" class="boxss" @click="kh(item.id)">
          <div><img src="../assets/aaa.jpg" alt="" /></div>
          <div>{{ item.name }}</div>
        </div>
      </div>
    </div>
    <div class="footer">
      <div class="index" @click="index()">
        <img src="../assets/sy.jpg" alt="" />
        <p style="color: #d8393e">首页</p>
      </div>
      <div @click="phb()">
        <img src="../assets/wpaihang.png" alt="" />
        <p>排行榜</p>
      </div>
      <div @click="my()">
        <img src="../assets/wmy.png" alt="" />
        <p>个人中心</p>
      </div>
    </div>
  </div>
</template>

<script>
// @ is an alias to /src
import axios from "axios";
export default {
  data() {
    return {
      changeRed: 0,
      bannerimg: [],
      box: [
        { name: "教师功底", id: 1 },
        { name: "贡献参与度", id: 2 },
        { name: "客户满意度", id: 3 },
        { name: "教师荣誉", id: 4 },
      ],
      boxs: [
        { subname: "学科组长", id: 1 },
        { subname: "优秀演讲师", id: 2 },
        { subname: "部门培训师", id: 3 },
        { subname: "产品研发师", id: 4 },
        { subname: "续班能手", id: 5 },
      ],
      list: [],
    };
  },
  methods: {
    qhk(index) {
      this.changeRed = index;
    },
    kh(e) {
      // this.$router.push("/Tes");
       this.$router.push({ path: "Tes", query: { id: e } });
    },
    jieshao(e) {
      localStorage.setItem("jsid", e), this.$router.push("/Teacher");
    },
    phb() {
      this.$router.push("/Ranking");
    },
    my() {
      this.$router.push("/Center");
    },

    qhid(a) {
      let this_ = this;
      axios
        .get("/Hmoepage/honor?honor=" + a)
        .then(function (res) {
          console.log(res.data.data), (this_.list = res.data.data);
          var honor = res.data.data.honor;
          localStorage.setItem("honors", honor);
        })
        .catch(function (err) {
          console.log(err);
        });
    },
  },
  created() {
    //banner
    let this_ = this
      axios
       .get('/Hmoepage/banner')
       .then(function(res){this_.bannerimg=res.data.data})
       .catch(function(err){console.log(err);});
       axios
       .get('/Hmoepage/honor')
       .then(function(res){ console.log(res.data.data),this_.list=res.data.data})
       .catch(function(err){console.log(err);});
  }
} 
</script>
<style scoped>
.center {
  width: 90%;
  margin: 1rem auto;
}
.biao {
  font-size: 0.8rem;
}
.biao img {
  margin-right: 0.5rem;
  width: 1rem;
  height: 1rem;
}
.subs {
  text-align: center;
  font-size: 0.5rem;
}
.subs img {
  width: 2rem;
  height: 2rem;
}
.touxiang {
  width: 3rem;
  height: 3rem;
  border-radius: 1.5rem;
  text-align: center;
  margin-left: 1rem;
}
.touxiang img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
}
.center .a {
  padding: 0.5rem 1.3rem;
}
.box {
  margin: 1rem 0;
  box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.12), 0 0 6px 0 rgba(0, 0, 0, 0.04);
  display: flex;
  justify-content: space-between;
  padding: 0.5rem;
  border-radius: 0.8rem;
}
.boxs {
  margin: 1rem 0;
  display: flex;
  justify-content: space-between;
  padding: 0.5rem;
  text-align: center;
  margin-bottom: 5rem;
  font-size: 0.5rem;
}
.boxss {
  box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.12), 0 0 6px 0 rgba(0, 0, 0, 0.04);
  border-radius: 0.8rem;
  width: 20%;
  padding: 0.5rem 0.2rem;
  color: #237878;
}
.boxss img {
  width: 90%;
}
.sub {
  font-size: 0.6rem;
  padding-bottom: 0.3rem;
  font-weight: 600;
}
.red {
  color: #d42329;
  border-bottom: 0.2rem solid #d42329;
}
.yh {
  margin-top: 1rem;
  font-size: 0.5rem;
}
.yh img {
  vertical-align: middle;
  margin-left: 0.8rem;
  margin-right: 0.5rem;
  width: 20px;
  height: 20px;
  padding-bottom: 0.2rem;
}
.yh span {
  font-size: 0.5rem;
  background: #fcfcfc;
  color: #a5a5a5;
  margin-left: 0.3rem;
}
.zwjs {
  font-size: 0.5rem;
  color: #fff;
  background: #f88777;
  width: 4rem;
  line-height: 1.3rem;
  text-align: center;
  height: 1.3rem;
  border-radius: 1.1rem;
  margin-top: 0.9rem;
  margin-right: 1rem;
}
.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}
.el-carousel__item:nth-child(2n + 1) {
  background-color: #d3dce6;
}
.el-carousel__button {
  height: 10px !important;
  width: 10px !important;
  border-radius: 5px;
}
.footer {
  display: flex;
  justify-content: space-around;
  font-size: 0.8rem;
  text-align: center;
  border-top: 1px solid #ccc;
  position: fixed;
  bottom: 0;
  width: 100%;
  background: #fff;
  padding: 5px 0;
}
.footer div {
  text-align: center;
}
.footer img {
  display: block;
  width: 2rem;
  height: 1.8rem;
  margin: 0 auto;
}
</style>
